﻿// -----------------------------------------------------------------------
// <copyright file="MainViewModel.cs" company="Microsoft">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace mmonkey.ViewModels
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Input;
    using GalaSoft.MvvmLight;
    using mmonkey.Commands;
    
    /// <summary>
    /// MainWindow View Model
    /// </summary>
    public class MainViewModel : ViewModelBase
    {
        private readonly ICommand _exitCommand;
        private readonly ICommand _aboutCommand;
        private readonly ICommand _startCommand;
        private readonly ICommand _stopCommand;
        private bool _controlsEnabled = true;

        public MainViewModel()
        {
            this._exitCommand = new DelegateCommand(DoExit);
            this._startCommand = new DelegateCommand(DoStart);
            this._stopCommand = new DelegateCommand(DoStop);
        }

        public bool ControlsEnabled
        {
            get { return this._controlsEnabled; }
            set
            {
                this._controlsEnabled = value;
                RaisePropertyChanged("ControlsEnabled");
            }
        }

        #region Commands

        public ICommand ExitCommand
        {
            get { return this._exitCommand; }
        }

        public ICommand AboutCommand
        {
            get { return this._aboutCommand; }
        }

        public ICommand StartCommand
        {
            get { return this._startCommand; }
        }

        public ICommand StopCommand
        {
            get { return this._stopCommand; }
        }

        #endregion

        public void DoExit(object state)
        {
            Application.Current.Shutdown();
        }

        public void DoShowAbout(object state)
        {
        }

        public void DoStart(object state)
        {
            this.ControlsEnabled = false;
        }

        public void DoStop(object state)
        {
            this.ControlsEnabled = true;
        }

    }
}
